package com.shihb.principle.segregation.olddemo;
/**
 *Description:违反接口隔离原则的demo
 *Version:1.0.0
 *@author shihb
 *@date 2020/6/23 21:03
 */
public class Demo1 {

  public static void main(String[] args) {

    // 将接口拆分，实现接口隔离原则，用到什么接口实现什么接口
    C c = new C();
    c.depend1(new A());
    c.depend2(new A());
    c.depend3(new A());
    D d = new D();
    d.depend1(new B());
    d.depend2(new B());
    d.depend3(new B());
  }

}

class C {
  public void depend1(Interface1 a){
    a.test1();
  }
  public void depend2(Interface2 a){
    a.test2();
  }
  public void depend3(Interface2 a){
    a.test3();
  }
}
class D {
  public void depend1(Interface1 b){
    b.test1();
  }
  public void depend2(Interface3 b){
    b.test4();
  }
  public void depend3(Interface3 b){
    b.test5();
  }
}




interface Interface1{
  public void test1();
}
interface Interface2{
  public void test2();
  public void test3();
}
interface Interface3{
  public void test4();
  public void test5();
}
class A implements  Interface1,Interface2{

  @Override
  public void test1() {
    System.out.println("A 实现了 test1");
  }

  @Override
  public void test2() {
    System.out.println("A 实现了 test2");
  }

  @Override
  public void test3() {
    System.out.println("A 实现了 test3");
  }

}
class B implements  Interface1,Interface3{

  @Override
  public void test1() {
    System.out.println("B 实现了 test1");
  }

  @Override
  public void test4() {
    System.out.println("B 实现了 test4");
  }

  @Override
  public void test5() {
    System.out.println("B 实现了 test5");
  }
}
